// @ts-ignore
/* eslint-disable */
import { requestAuth } from '@/utils/request';

/** 获取岗位列表 */
export async function fetchJobList(data: {
  size: number;
  current: number;
  params?: {
    column: string;
    type: string;
    values?: string;
  }[];
}) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/page',
    data,
  });
}

/** 检查岗位编码是否重复 */
export async function checkJobCode(data: { id?: string; postCode: string }) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/check',
    data,
  });
}

/** 新增岗位 */
export async function addJob(data: {
  postCode: string;
  postName: string;
  postSort: number;
  postStatus: string;
}) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/save',
    data,
  });
}

/** 编辑岗位 */
export async function modifyJob(data: {
  id: string;
  postCode: string;
  postName: string;
  postSort: number;
  postStatus: string;
}) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/update',
    data,
  });
}

/** 删除岗位 */
export async function deleteJobById(data: { id: string }) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/delete',
    data,
  });
}

/** 批量删除岗位 */
export async function batchDeleteJobByIds(data: { ids: string[] }) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/deleteBatch',
    data,
  });
}

/** 查询岗位关联的机构列表 */
export async function fetchJobDepartmentRelation(data: { postId: string }) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/postOrganList',
    data,
  });
}

/** 更新角色关联机构 */
export async function updateJobDepartmentRelation(data: {
  postId: string;
  organList: string[]
}) {
  return requestAuth({
    method: 'POST',
    url: '/api/system/post/bindOrganList',
    data,
  });
}
